<template>

  <view @click="isMore = false">
    <u-popup
        :round="10"
        :safeAreaInsetBottom="false"
        :show="sharePlacardVis"
        mode="center"
        @close="closeImgShare"
        bgColor="transparent"
    >

      <l-painter ref="posterRef" css="width: 550rpx" path-type="url">
        <l-painter-view css="background: #fff">
        <l-painter-view css="position: absolute;top: 46rpx;width: 340rpx;text-align:left;margin-left:24rpx">
          <l-painter-text css="font-weight: bold;color: #fff;font-size: 30rpx;" style="" :text="`${shopInfo.shopname+shopInfo.suffix}`">  </l-painter-text>
        </l-painter-view>

        <l-painter-image
            src="@/static/qrcode-tpl-top.png"
            css="width: 100%;"
        />
        <l-painter-image
            :src="goodsInfo.images[openSwiper]"
            css="width: 100%;"
        />
        <l-painter-view css="position:relative;vertical-align: middle;background:#fff;padding:0 20rpx;">
          <l-painter-text :text="`￥${goodsInfo.user_price.toFixed(2)}`" css="padding-bottom: 10rpx; color: red; font-size: 32rpx; fontWeight: bold"/>
          <l-painter-text text="正品保障" css="background:red;border-radius:6rpx;color:#fff;font-size: 22rpx;margin-left: 10rpx;display:inline-block;text-align:center;padding:0rpx 8rpx"/>
        </l-painter-view>

        <l-painter-view css="display: flex;padding:0 20rpx;background:#fff;vertical-align: middle;">
          <l-painter-text class="tag t1"  uid="tag1" css="background:rgb(92, 179, 108);position:absolute; top:3rpx; border-radius:6rpx;color:#fff;font-size: 22rpx;margin-left: 20rpx;text-align:center;padding:0rpx 8rpx" text="保税"  v-if="goodsInfo.trade_type == 1101"> <!----></l-painter-text>
          <l-painter-text class="tag t3"  uid="tag1" css="background:rgb(244, 164, 53);position:absolute;top:3rpx;   border-radius:6rpx;color:#fff;font-size: 22rpx;margin-left: 20rpx;text-align:center;padding:0rpx 8rpx" text="一般贸易" v-else-if="goodsInfo.trade_type == 2202"><!----></l-painter-text>
          <l-painter-text class="tag t2" uid="tag1" css="background:red;position:absolute;  top:3rpx; border-radius:6rpx;color:#fff;font-size: 22rpx;margin-left: 20rpx;text-align:center;padding:0rpx 8rpx" text="直邮" v-else> <!----></l-painter-text>
          <l-painter-text :text="`${goodsInfo.name}`" css=" text-indent: calc(tag1.width - 18rpx);font-size: 24rpx;flex: 1;box-sizing: border-box; line-clamp: 2;border:1px solid #fff"></l-painter-text>
        </l-painter-view>
        <l-painter-view css="display: flex;padding-left:4rpx;align-items: center;justify-content:space-around;background:#fff;margin-bottom: 5rpx;border:1px solid #fff " style="">
          <l-painter-text text="扫码抢每日福利" css="padding-bottom: 10rpx; color: #8463A8; font-size: 32rpx; align-content:flex-start;fontWeight: bold"/>
          <l-painter-image
              :src="invite_src"
              css="width: 160rpx;height:160rpx;justify-content:flex-start"
          />
        </l-painter-view>
        </l-painter-view>
      </l-painter>

      <view class="share-save-box">
        <button class="save" @click="saveImgShare"><image src="@/static/save-qrcoe.png" mode="widthFix" style="width: 30rpx"/>保存到手机</button>
        <button class="zf" @click="closeImgShare"><image src="@/static/zhuangf.png" mode="widthFix" style="width: 30rpx"/>关闭</button>
      </view>
    </u-popup>

    <u-loading-page :loading="pageloading"  icon-size="30" fontSize="14" loadingColor="#AE87D8" color="#AE87D8" loading-text="加载中..."></u-loading-page>
    <view v-if="!pageloading">
      <view class="goods-head" :style="'background:rgba(255,255,255,' + PageScrollTop / 100 + ')'">
        <!-- 返回 -->
        <!--      <view class="back" @click="onBack">
                <view class="back-one" :class="{ action: PageScrollTop > 120 }">
                  <text></text>
                </view>
                <view :class="{ action: PageScrollTop > 120 }" class="back-one" style="margin-left: 5rpx;width: 52rpx;height: 52rpx" >
                  <u-icon name="home"  size="24" :bold="false" :color="PageScrollTop > 120?'':'#fff'"></u-icon>
                </view>
              </view>-->
        <back :page-scroll-top="PageScrollTop"/>
      </view>
      <!-- banner，标题 -->
      <view class="banner-title">
        <!-- banner -->
        <view class="banner">
          <swiper class="screen-swiper square-dot" indicator-dots="true" circular="true" autoplay="true" interval="5000" duration="500" :current="currentswiper" @change="swiperChange">
            <swiper-item v-for="(item, index) in goodsInfo.images" :key="index" :show-menu-by-longpress="true" @click="save($event,index)" :id="`it${index}`" >
              <image :src="item" mode="aspectFill" :show-menu-by-longpress="true" :data-url="item" class="imgit"></image>
              <!-- <video src="{{item.url}}" autoplay loop muted show-play-btn="{{false}}" controls="{{false
              }}" objectFit="cover" wx:if="{{item.type == 'video'}}"></video> -->
            </swiper-item>
          </swiper>
        </view>
        <!-- 价格 -->
        <view class="price-info" >
          <view class="user-price">
            <text class="min"  style="font-size: 34rpx;">{{goodsInfo.price0_text || ''}}</text>
            <text class="max"  style="font-weight: bold">￥{{goodsInfo.price0 || 0}}</text>
          </view>
          <view class="vip-price"  v-if="goodsInfo.hasOwnProperty('price1')">
            {{goodsInfo.price1_text || ''}}
            <text>￥{{goodsInfo.price1 || 0}}</text>
          </view>
        </view>
        <!-- 标题 -->
        <view class="goods-title">
          <text :selectable="true">
            <text class="tag t1" v-if="goodsInfo.trade_type == 1101" >保税</text>
            <text class="tag t3" v-else-if="goodsInfo.trade_type == 2202">一般贸易</text>
            <text class="tag t2" v-else>直邮</text>
            {{goodsInfo.name}}    </text>

          <image @tap="copyBtn(goodsInfo.name)"  style="height: 50rpx;width:50rpx;justify-content: center;
    vertical-align: middle;" mode="aspectFit" src="@/static/copy.png"/>
        </view>

      </view>

      <!-- 属性规格 -->
      <view class="goods-discounts" v-if="hasLogin && swLevel > 0">
        <view class="list" @click="sharePlacard()">
          <!-- <view class="title" style="width:initial;">已选</view> -->
          <view class="content" style="width: 70%" >
            <text style="font-size:28rpx;">卖它最高可赚{{goodsInfo.shopkeeper_brokerage.toFixed(2)}}元</text>
          </view>
          <view class="more">
            <text style="color: #ae87d8">生成海报 </text>
            <text class="iconfont icon-more"></text>
          </view>
        </view>
      </view>

      <!-- 属性规格 -->
      <view class="goods-discounts">
        <view class="list" @click="attrClick(2)">
          <!-- <view class="title" style="width:initial;">已选</view> -->
          <view class="content" >
            <text style="font-size:28rpx;">请选择规格</text>
          </view>
          <view class="more">
            <text class="iconfont icon-more"></text>
          </view>
        </view>
      </view>

      <!-- 专区 -->
      <view class="goods-discounts" v-if="goodsInfo.brand.id" @click="toCateoryList(goodsInfo.brand.id)">
        <view class="list flex-box zList" style="height:initial;">
          <view class="img-1">
            <image style="width:120rpx;border-radius:50%;" class="img" :src="goodsInfo.brand.logo" mode="aspectFill"></image>
          </view>
          <view class="box-1 cont" style="width:initial;margin-left:20rpx;">
            <view class="head">{{goodsInfo.brand.name}}</view>
            <view class="desc" style="margin-top:5rpx;color:#999;">{{goodsInfo.brand.goods_num}}款商品在售</view>
          </view>
          <view class="more" style="color:#999;">
            查看专区
            <text class="iconfont icon-more"></text>
          </view>
        </view>
      </view>
      <!-- 商品参数 -->
      <view class="can-box" v-if="false">
        <view class="title">商品参数</view>
        <view class="can-list">
          <view class="li flex-box">
            <view class="a1">品牌</view>
            <view class="a2">赫莲娜 HR</view>
          </view>
          <view class="li flex-box">
            <view class="a1">产地</view>
            <view class="a2">赫莲娜 HR</view>
          </view>
          <view class="li flex-box">
            <view class="a1">有效期</view>
            <view class="a2">赫莲娜 HR</view>
          </view>
          <view class="li flex-box">
            <view class="a1">库存</view>
            <view class="a2">赫莲娜 HR</view>
          </view>
          <view class="li flex-box">
            <view class="a1">货号</view>
            <view class="a2">赫莲娜 HR</view>
          </view>
        </view>
      </view>

      <!-- 商品介绍 -->
      <view class="products-introduction" ref="products">
        <view class="title">
          <text style="margin:0;">商品详情</text>
        </view>
        <view class="content" >
          <image v-for="(g,i) in goodsInfo.detail" mode="widthFix"  show-menu-by-longpress :style="{height:imgHeight+'px'}" @load="onImgLoad" :src="g" @tap="save"></image>
        </view>
        <!--    购买须知  -->
        <view>
          <view style="text-align: center;font-weight: bold;font-size: 30rpx;margin: 10rpx">一 购买须知 一</view>
          <rich-text :nodes="buy_desc"></rich-text>
        </view>
      </view>
      <!-- 底部 -->
      <view class="page-footer">
        <view class="footer-fn">
          <view class="list">
            <image class="img" @click="kefu" src="../../static/kf-1.png" mode="aspectFill"></image>
            <text>客服</text>

          </view>
<!--          <view class="list" @click="onToCart">
            <image class="img" src="../../static/cat-1.png" mode="aspectFill"></image>
            <text>购物车</text>
          </view>-->
        </view>
        <view class="footer-buy">
<!--          <view class="cart-add" @click="attrClick(2)">
            <text style="color:rgb(135, 103, 65);">加入购物车</text>
          </view>-->
          <view class="buy-at" @click="attrClick(3)">
            <text>立即购买</text>
          </view>
        </view>
      </view>
      <!-- 客服热线 -->
      <view class="serve-hotline" @click.stop="isHotline = false">
        <view class="cu-modal bottom-modal" :class="{'show':isHotline}">
          <view class="cu-dialog">
            <view class="contact-list">
              <view class="list">
                <text @click.stop="callPhone(kfInfor.tel)">电话客服{{kfInfor.tel}}</text>
              </view>
              <!-- <view class="list">
                <button open-type="contact" class="custom-button"><text>在线客服</text></button>
              </view> -->
              <view class="list">
                <text class="btn" style="color:#fff;">取消</text>
              </view>
            </view>
          </view>
        </view>
      </view>
      <!-- 服务弹窗 -->
      <goods-serve ref="GoodsServe"></goods-serve>
      <!-- 优惠券 -->
      <goods-coupon ref="GoodsCoupon"></goods-coupon>
      <!-- 属性规格 -->
      <goods-attr
          :GoodsAttr="GoodsAttrList"
          :hasLogin="hasLogin"
          @changeAid="changedis"
          @changeAddress="changeAddress"
          :type="goodsInfo.trade_type"
          @closeShow="getClose"
          :goodsInfo="goodsInfo"
          :isShow="attrShow" ref="attr"
          :skuerror="skuError"
          :skuerror-msg="skuErrorMsg"
      ></goods-attr>
    </view>
  </view>
</template>
<style lang="scss">
.share-save-box{
  //position: fixed;
  //bottom: 5%;
  width: 100%;
  margin: 0 auto;
  vertical-align: middle;
  button{
    display: inline-block;
    width:50%;
    font-size: 26rpx;
    color: #fff;
    height: 62rpx;
    image{
      position: relative;
      top: 6rpx;
      margin-right: 6rpx;
      width: 24rpx;
    }
  }
  .save{
    border-top-left-radius: 30rpx;
    border-bottom-left-radius: 30rpx;
    background: #D9A26B;
  }
  .zf{
    background: #996699;
    border-bottom-right-radius: 30rpx;
    border-top-right-radius: 30rpx;
  }
}
</style>
<script>
import GoodsServe from '../../components/GoodsServe/GoodsServe.vue';
import GoodsCoupon from '../../components/GoodsCoupon/GoodsCoupon.vue';
import GoodsAttr from '../../components/GoodsAttr/GoodsAttr.vue';
import back from '../../components/headback/back.vue';
	import {
		mapState
	} from 'vuex'
import qqmapsdk from "@/utils/qqmap-wx-jssdk.min";
export default {
  components: {
    GoodsServe,
    GoodsCoupon,
    GoodsAttr,
    back
  },
  data() {
    return {
      skuError:false,
      skuErrorMsg:'',
      pageloading:true,
		kfInfor:{},
		district_id:110101,
		attrShow:false,
		GoodsAttrList:[],
		isHotline:false,
	  addressInfor:{},
      TabShow: 0,
      isMore: false,
      AttentionShow: 0,
      swLevel:0,
	  goodsInfo:{},
      swiperList: [
        {
          id: 0,
          type: 'image',
          url: '/static/img/goods_banner_01.webp'
        },
      
      ],
      web_content:
          '<div class="m-img"><img src="https://zhedplus.oss-cn-hangzhou.aliyuncs.com/content_img/20191118/1fb5ff162f25fd4c7383bd998ff2fde9.jpg"><div class="tools" hidden><i class="fa fa-arrow-up move-up"></i><i class="fa fa-arrow-down move-down"></i><em class="move-remove" hidden ><i class="fa fa-times" aria-hidden="true"></i> 移除</em><div class="cover"></div></div></div>',
      PageScrollTop: 0,
			type: 0,
			imgHeight:0,
			code:0,
      buy_desc:`  <p>尊敬的客户：</p>
        为了帮助您更好的选购境外商品，请您在购买前务必认真详细阅读并完全理解本告知书的全部内容，并对自身风险承担做出客观判断。请您确认同意本告知书内容后再下单购买。如有在本平台下单购买之行为，视为同意本告知书的内容：<br><br>

        1）您在平台购买的境外商品等同于原产地直接销售商品，<b>因此商品本身可能无中文标签</b>，如有需要，您可以查看网站相关商品的中文翻译或者在线联系客服；<br>

        2）根据相关法律政策，<b>您选购的商品仅限于受消费者个人用户委托代购或您个人自用，不得以任何形式在线上线下留存或再次销售。当您为代购用户时，您可能不适用消费者（自然人）相关法规条款。</b><br>

        3）<b>您购买的境外商品均符合原产地有关品质、健康、标识的相关标准，但可能与我国产品标准或有所不同，由此可能造成的危害、损失或其他风险，将由您个人承担，平台不承担责任。</b><br>

        4）<b>平台销售的相关商品均由商家供应，由商家承担其商品的质量保证责任。平台对商品的审核和承诺并不减免商家的任何责任。</b><br>

        5）在购买境外商品时，您知悉并认可：（1）您是从相关海外实体商家订购商品；（2）在购买之时商品尚未进口到内地（香港特别行政区、澳门特别行政区、台湾除外）；<b>（3）该销售发生在海外销售（以商品产地为准），适用原商品销售国法律及法院管辖。</b><br>

        6）请您确保您在平台所使用的消费者身份信息在整个注册、购买及收货过程中是真实、合法、有效的；您承诺不以任何形式在平台刷单，不利用平台进行任何违法活动。<br>

        7）您知晓并同意平台有权在您违反本承诺保证时，对您处以锁定交易、暂停服务、关停账户等措施并有权要求您赔偿因违反本承诺保证对平台造成的全部损失。<br>

        8）<b>因同商品或可能涉及到不同的仓库，而发货仓库不同，货物配送至您手中的时限会稍有区别，对于商品效期也会因分仓调配问题按照最优效期给到您，均请以实际为准；</b><br>

        9）请您保持联系方式畅通，在快递员送货过程中，若因您方原因未能及时回复快递员或与之取得联络，此订单将被默认为您已经放弃订购，由此产生的费用或其他损失由您自行承担；<br>

        10）<b>境外商品不支持无理由退换货，不支持无理由拒收</b>，此类商品如被拒收或退回，将扣除50%的订单总金额，请您务必收到货时在快递员见证下先拆包检查。<b>（商品中如含功效成分解说的内容，为营养科普知识，仅供参考，内容不代表产品功效，请理解性阅读和购买。</b>其他售后问题请参考帮助中心售后服务）。<br>
        <br>
        补充说明：
        <br>
        a）根据财政部，海关总署，国家税务总局规定，参照中华人民共和国财政部关税【2018】49号《关于完善跨境电子商务零售进口税收政策的通知》要求，跨境电子商务零售进口商品的单次交易限值为人民币5000元，个人年度交易限值为人民币26000元。在限值以内进口的跨境电子商务零售进口商品，进口环节增值税、消费税取消免征税额，暂按法定应纳税额的70%征收。对于违反上述规定的系统将给予退单；
        <br>
        b）什么是保税区？
        <br>
        保税区是海关设置的或经海关批准注册、受海关监督和管理的可以较长时间存储商品的区域。（保税区能便利转口贸易，增加有关费用的收入。 外国商品存入保税区，不必缴纳进口关税，尚可自由出口，只需交纳存储费和少量费用，但如果要进入关境则需交纳关税。）
        <br>
        c）跨境婴幼儿奶粉按照国际标准生产，其蛋白质含量可能低于国内标准，长期喂食会造成婴幼儿蛋白质摄入不足，建议及时补充肉类或鱼类辅食。
        <br>
        d）国家药监局提示您：化妆品不能宣称医疗作用，也没有治疗作用，宣称治疗儿童湿疹等皮肤病的产品不属于化妆品。`,
      sharePlacardVis:false,
      shopInfo:{},
      invite_src:{},
      currentswiper:0,
      openSwiper:0
		};
		
  },
	onLoad(params) {
		console.log(params,'params')
		this.id = params.id||0;
		// let scene =
    if (params.scene){
      let scene = decodeURIComponent(params.scene).split(',');
      this.code = scene[0]
      if ( scene[1]){
        this.id = scene[1]
      }
    }
    if(!params.scene || this.hasLogin){
			this.code = uni.getStorageSync('userInfo').code;
		}
		uni.setStorageSync('goodsId', this.id);
		this.getGoodsDetails()
		this.initData();

	},
	onShow(){
		if(this.hasLogin){
			// this.getCode()
			// console.log(this.hasLogin,this.code,111111)
			this.getShopInfo();
		}
    this.$refs.attr?.initData();
	},
	onShareAppMessage: function() {
		 return {
			title:this.goodsInfo.name,
			path:'/pages/GoodsDetails/lrGoodsDetails?id='+this.id+'&scene='+this.code,
			imageUrl:this.goodsInfo.images[0]
		 }
	},
			//分享到朋友圈
	onShareTimeline(res) {
		return {
		   title:this.goodsInfo.name,
		   path:'/pages/GoodsDetails/lrGoodsDetails?id='+this.id+'&scene='+this.code,
      imageUrl:this.goodsInfo.images[0]
		}
	},
	computed: {
		...mapState(['hasLogin','userInfo'])
	},
	onPageScroll(e) {
		this.PageScrollTop = e.scrollTop;
		
	},
  methods: {
    closeImgShare(){
      this.sharePlacardVis=false
    },
    swiperChange(e){
      this.currentswiper = e.detail.current
      // console.log(e)
    }
    ,
    saveImgShare() {
      this.$refs.posterRef.canvasToTempFilePathSync({
        fileType: 'png',
        quality: 1,
        success: (res) => {
          // console.log(res.tempFilePath)
          // this.picture2 = res.tempFilePath
          uni.saveImageToPhotosAlbum({
            filePath: res.tempFilePath,
            success(res) {
              uni.showToast({
                title: '已保存到相册',
                icon: 'success',
                duration: 2000
              });
            },
          });
        },
        fail(e) {
          // console.log('???????????',e)
        }
      })
    },
    wxShareImg() {
      this.$refs.posterRef.canvasToTempFilePathSync({
        fileType: 'png',
        quality: 1,
        success: (res) => {
          wx.downloadFile({
            url:res.tempFilePath, // 分享的图片的链接
            success: (res) => {
              wx.showShareImageMenu({
                path: res.tempFilePath
              })
            }
          })
        }})

    },
    sharePlacard(){
      console.log(this.currentswiper)
      this.$u.api.inviteCode({page:'pages/GoodsDetails/lrGoodsDetails',param:this.goodsInfo.id})
          .then(res=>{

            // this.q = res.msg
            this.invite_src = res.msg.ewm;
            this.sharePlacardVis = true;
            this.openSwiper = this.currentswiper;
            // uni.setStorageSync('code', res.msg.code);
            // #ifdef APP-PLUS
            // this.$refs.uniqrcode.make(this.info.link);
            //#endif
          })
          .catch(err=>{
            console.log(err);
          })

    },
    save(e,index){
      const query = uni.createSelectorQuery();     //这样写就只会选择本页面组件的类名box的
      // console.log('#it'+index)
      query.select('#it'+index+" .imgit").boundingClientRect(data => {   //回调函数，data中存储的是这些元素节点（每个节点的信息存为一个对象）的位置信息
        // console.log(data.dataset.url)
        // console.log("得到布局位置信息" + JSON.stringify(data));
        // console.log("节点离页面顶部的距离为" + data[1].top);  //本页面共有三个，这里我只打印第二个的
        uni.previewImage({
          current:data.dataset.url,
          urls:this.goodsInfo.images
        })
      }).exec();


     // console.log(e.currentTarget.querySelector('image'))
      console.log(e,"长按保存")
    }
    ,
    copyBtn(title) {
      let that = this;
      wx.setClipboardData({//复制文本
        data: title,
        success: function (res) {
          wx.showToast({
            title: '复制成功',
            icon: "none",
            mask: "true"//是否设置点击蒙版，防止点击穿透
          })
        }
      })
    },
      kefu(){
      uni.navigateTo({url:'/pages/sub/service/service'})
    },
    changeAddress(item){
      //更改地址,再触发回调
      // console.log(item)
      uni.showLoading();
      this.$u.api.goodsSku({id:this.id,area_id:item.district_id,num:1}).then(res => {

        if (res.status) {
          this.skuError = false;
          this.skuErrorMsg = '';
          this.GoodsAttrList = res.msg;
        }else{
          this.GoodsAttrList = {life:[],sku:[],spec:[]};
          this.skuError = true;
          this.skuErrorMsg = res.msg;
        }
        console.log("goodsattr")
        console.log(this.GoodsAttrList);
        uni.hideLoading();
      })
      .catch(err => {
        console.log(err);
        uni.hideLoading();
      })
    },
	  getCode(){
	  	this.$u.api.inviteCode()
	  	.then(res=>{
	  		this.code = res.msg.code
	  		uni.setStorageSync('code', res.msg.code);
	  		uni.setStorageSync('goodsId', res.msg.code);
	  	})
	  	.catch(err=>{
	  		console.log(err);
	  	})
	  },
	  initData(){
	  	this.$u.api.souceKf()
	  	.then(res=>{
	  		console.log(res.msg);
	  		if(res.status){
	  			this.kfInfor = res.msg
	  			return 
	  		}
	  	})
	  	.catch(err=>{
	  		console.log(err);
	  		uni.showToast({
	  			icon: 'none',
	  			title: "网络异常，请稍后"
	  		})
	  	})
	  },
    getShopInfo(){
      this.$u.api.shopInfo().then(res => {
        if (res.status) {
         /* this.shopInfo = res.msg
          this.show = res.msg.show*/
          console.log(res.msg)
          this.shopInfo = res.msg;
          this.swLevel = res.msg.sw_level;
        }
        // console.log(this.swLevel)
      }).catch(err => {
            console.log(err);
      });
    },
	  changedis(id){
		  this.district_id = id
	  },
	  callPhone(phoneNumber) {
	    // 判断手机是否支持拨打电话功能
	    if (uni.canIUse('makePhoneCall')) {
	  	uni.makePhoneCall({
	  	  phoneNumber: phoneNumber, // 电话号码
	  	  success: function () {
	  		console.log('拨打电话成功');
	  	  },
	  	  fail: function () {
	  		console.log('拨打电话失败');
	  	  }
	  	});
	    } else {
	  	console.log('你的设备不支持拨打电话功能');
	    }
	  },
	  toCateoryList(id){
	  	uni.navigateTo({url:'/pages/SearchGoodsList/SearchGoodsList?brand_id='+id})
	  },
	  onImgLoad(e){
		  const {width,height} = e.mp.detail;
		  this.imgHeight = (height/width)*100
	  },
	  getClose(res){
		  this.attrShow = res
	  },
	  attrClick(type){
		  if (!this.hasLogin) {
		  	uni.navigateTo({
		  		url: '/pages/login/login?scene='+this.code,
		  	})
			return
		  }
		  this.clickSku()
	  },
	  // 获取默认地址
	  getAddress(){  
	    this.$u.api.addressMess().then(res => {
	  		if (res.status) {
				  this.getgLocation();
	  			this.addressInfor = res.msg
	  		}
	  	})
	  	.catch(err => {
	  		console.log(err);
	  	})
	  },


	  /**
	   * sku
	   */
	  clickSku(){
      this.attrShow = true;
      // console.log(this.$refs.attr.address)
		/*  this.$u.api.goodsSku({id:this.id,area_id:this.district_id,num:1}).then(res => {
		  		if (res.status) {
		  			this.GoodsAttrList = res.msg
		  		}
		  	})
		  	.catch(err => {
		  		console.log(err);
		  	})*/
	  },
	  /**
	   * 我的服务点击
	   */
	  onServer(type){
	  	switch (type){
	  		
	  		case 'serve':
	  			this.isHotline = true;
	  			break;
	  	}
	  },
	  /**
	   * 去购物车
	   */
	  onToCart() {
		  if (!this.hasLogin) {
		  	uni.navigateTo({
		  		url: '/pages/login/login?scene='+this.code,
		  	})
		  	return
		  	
		  }
			uni.navigateTo({
			  url: '/pages/cart/cart'
			})
	  },
	  // 详情
	  getGoodsDetails(){
	  	this.$u.api.goodsDetail({id:this.id}).then(res => {
	  			if (res.status) {
	  				this.goodsInfo = res.msg
	  			}else{

          }
        this.pageloading = false;
	  		})
	  		.catch(err => {
	  			console.log(err);
          this.pageloading = false;
	  		})
	  },
	  // 购买
	  confimOrder(id){
			if (!this.hasLogin) {
				uni.navigateTo({
					url: '/pages/login/login?scene='+this.code,
				})
				return
			}else{
				if(this.goodsInfo.flag=='vip'&&this.goodsInfo.sw_level>=1){
					uni.showToast({
						title: '新人福利仅限购买一次',
						icon: 'none',
						duration: 3000,
						success(){
							// uni.navigateBack()
						}
					});
				}else{
					uni.navigateTo({url:'/pages/ConfirmOrder/ConfirmOrder?id='+this.goodsInfo.id})
				}
			}
			return false
			this.$u.api.ordersPre({goods_id:id}).then(res => {
					if (res.status) {
						
					}
				})
				.catch(err => {
					console.log(err);
				})
		  
	  },
    /**
     * 返回
     */
    onBack() {
      uni.navigateBack();
    },
  }
};
</script>

<style scoped lang="scss">
@import 'GoodsDetails.scss';

.tag {
  top:-3rpx;
  position: relative;
  background-color: $base;
  border-radius: 6rpx;
  margin-right: 4px;
  padding: 1rpx 8rpx;
  //margin: 0;
  display: inline-block;
  //height: 28rpx;
  //text {
  //width: 36rpx;
  //display: inline-block;
  color: #ffffff !important;
  font-size: 22rpx !important;
  //transform: scale(0.7);
  //}

}
.t1{
  //保税
  background: rgb(92, 179, 108);
}
.t2{
  //直邮
  background: rgb(209, 34, 39);
}
.t3{
  //一般贸易
  background: rgb(244, 164, 53);
}
/* 客服热线弹窗 */
.serve-hotline{
	.cu-dialog{
		width: 100%;
		border-radius: 20rpx 20rpx 0 0 !important;
		padding:30rpx 0;
		.contact-list{
			width: 100%;
			.list{
				display: flex;
				align-items: center;
				justify-content: center;
				width: 100%;
				height: 100rpx;
				text{
					color: #222222;
					font-size: 32rpx;
				}
			}
			.btn{
				width:600rpx;
				height:90rpx;
				line-height:90rpx;
				text-align: center;
				color:#fff;
				background:#ae87d8;
				border-radius: 45rpx;
				color:#fff;
			}
		}
	}
}
.can-box{
	width:710rpx;
	margin:20rpx;
	background:#fff;
	border-radius: 10rpx;
	padding:30rpx;
	.title{
		font-size:32rpx;
		margin-bottom:20rpx
	}
	.can-list{
		font-size:26rpx;
		color:#5f5f5f;
		.li{
			background-color: #efefef;
			.a1{
				padding:20rpx 0;
				width:200rpx;
				text-align: center;
				border-right:2rpx solid #fff;
			}
			.a2{
				padding:20rpx;
			}
		}
		.li:nth-child(odd){
			background-color: #f7f7f7;
		}
	}
}
.zList{
		padding:10rpx 0;
	}
.img-1{
	.img{
		width:120rpx;
		height:120rpx;
		border-radius:50%;
	}
}
/* 优惠 */
.goods-discounts{
	padding: 0;
	background-color: #FFFFFF;
	border-radius: 10rpx;
	overflow: hidden;
	margin: 20rpx;
	.head{
		font-size:30rpx;
	}
	
}
/* 商品介绍 */
.products-introduction{
	padding: 0 4% 100rpx;
	text-align: left;
	background:#fff;
	.title{
		display: flex;
		justify-content: left;
		align-items: center;
		width: 100%;
		height: 80rpx;
		text{
			font-size: 32rpx;
			color: #212121;
			margin: 0 20rpx;
		}
	}
	.title:before{
		content: "";
		width: 0;
		height: 2rpx;
		background-color: #c0c0c0;
	}
	.title:after{
		content: "";
		width: 0;
		height: 2rpx;
		background-color: #c0c0c0;
	}
}
.page-footer{
	.img{
		width:32rpx;
		height:32rpx;
		display: block;
		margin:0 auto;
		margin-bottom:5rpx;
	}
	.footer-buy{
		display: flex;
		align-items: center;
		justify-content: center;
		width: 100%;
		height: 100%;
		.cart-add{
			display: flex;
			align-items: center;
			justify-content: center;
			width: 100%;
			height: 80rpx;
			background: linear-gradient(to right,$base,$assist-clor);
			border-radius: 80rpx;
			//border-top-right-radius: 0;
			//border-bottom-right-radius: 0;
			background:#f3d3ac;
			text{
				font-size: 26rpx;
				color: #bd9d75;
			}
		}
		.buy-at{
			display: flex;
			align-items: center;
			justify-content: center;
			width: 100%;
			height: 80rpx;
			background:#d0abf4;
			border-radius: 80rpx;
			//border-top-left-radius: 0;
			//border-bottom-left-radius: 0;
			background:#ae87d8;
			text{
				font-size: 26rpx;
				color: #FFFFFF;
			}
		}
	}
}
	
</style>
